package com.sky.controller.rider;

import com.sky.dto.UserLoginDTO;
import com.sky.pojo.Courier;
import com.sky.result.Result;
import com.sky.service.rider.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/courier")
public class LoginController {
    @Autowired
    private LoginService loginService;

    @GetMapping("/validateCodeToPhone")
    public Result<String> validateCodeToPhone(String telephone) throws Exception {
        String Code = loginService.validateCodeToPhone(telephone);
        return Result.success(Code);
    }
    @PostMapping("/login")
    public  Result<Courier> login(@RequestBody UserLoginDTO dto){
       Courier courier = loginService.login(dto);
       return Result.success(courier);
    }
}
